
***************BEGIN COMPUTING MOMENTS***************
use "$temp/nlsy_moment_data", clear
drop if hgc_final>20
gen coll_final = (hgc_final>=16)

su coll_final [fw=weight_17]

su coll_final [fw=weight_17] if parent_inc_quart == 1
su coll_final [fw=weight_17] if parent_inc_quart == 2
su coll_final [fw=weight_17] if parent_inc_quart == 3
su coll_final [fw=weight_17] if parent_inc_quart == 4

su coll_final [fw=weight_17] if ability == 1
su coll_final [fw=weight_17] if ability == 2
su coll_final [fw=weight_17] if ability == 3
su coll_final [fw=weight_17] if ability == 4
su coll_final [fw=weight_17] if ability == 5

su coll_final [fw=weight_17] if !parcoll
su coll_final [fw=weight_17] if parcoll


preserve
keep if !parcoll
gen count = 1/weight_17
collapse (mean) coll_final (sum) count  [fw=weight_17], by(parent_inc_quart ability)
ren parent_inc p
replace coll_final = 999 if count<=25
drop count
reshape wide coll_final, i(p) j(ability)
drop p
export delimited "$model/moments/attendance_noncoll.csv", novarn replace
restore


preserve
keep if parcoll
gen count = 1/weight_17
collapse (mean) coll_final (sum) count [fw=weight_17], by(parent_inc_quart ability)
ren parent_inc p
//replace coll_final = 999 if count<=25
drop count
reshape wide coll_final, i(p) j(ability)
drop p
export delimited "$model/moments/attendance_coll.csv", novarn replace
restore



gen count = 1
keep if parcoll
collapse (sum) count, by(parent_inc_quart ability)
ren parent_inc p
reshape wide count, i(p) j(ability)
drop p